package com.yh.user.service;

import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.yh.user.entity.User;
import com.yh.user.mapper.UserMapper;
import com.yh.user.pager.PageBean;
import com.yh.user.util.MybatisUtil;

public class UserService {
	private SqlSession sqlSession=MybatisUtil.getSqlSession();
    private UserMapper userMapper=sqlSession.getMapper(UserMapper.class);
    /**
     * 查询所有人信息
     * @return
     */
	public List<User> findAll(PageBean<User> pb){
		return userMapper.findAll(pb);
	}
	/**
	 * 删除信息
	 * @param user
	 */
	public void deleteUser(User user){
		userMapper.deleteUser(user);
		sqlSession.commit();
		
	}
	/**
	 * 根据id查询用户
	 * @param user
	 * @return
	 */
	public User findUserId(User user){
		return userMapper.findUserId(user);
	}
	/**
	 * 更新用户信息
	 * @param user
	 */
	public void updateUser(User user){
		userMapper.updateUser(user);
		sqlSession.commit();

	}
	/**
	 * 添加信息
	 * @param user
	 */
	public void insertUser(User user){
		userMapper.insertUser(user);
		sqlSession.commit();

	}
	/**
	 * 总记录数
	 * @return
	 */
	public int countUser(){
		return userMapper.countUser();
	}

}
